/********************************************************************************
  * @file     SD93F115B_vic.h   						    	
  * @author   TEST TEAM 												    	
  * @version  v0															    	
  * @date     Septemper 2022												    	
  * @brief 
  *           
  * Copyright (C) 2022  Hangzhou SDIC Microelectronics Co., Ltd  
*********************************************************************************/


/* Define to prevent recursive inclusion */
#ifndef __SD93F115B_VIC_H
#define __SD93F115B_VIC_H

#ifdef __cplusplus
 extern "C" 
 {
#endif 

#include "SD93F115B.h"
/*******************************中断向量号*****************************/

#define IS_VIC_IRQn(Channel) (((Channel) == SysTick_IRQn)||((Channel) == LBT_IRQn)||\
							  ((Channel) == XT1Fault_IRQn)||((Channel) == XT2Fault_IRQn)||\
							  ((Channel) == FLASH_IRQn)||((Channel) == EXINT0_IRQn)||\
							  ((Channel) == EXINT1_IRQn)||((Channel) == KEY_IRQn)||\
							  ((Channel) == UART0_IRQn)||((Channel) == UART1_IRQn)||\
							  ((Channel) == I2C_IRQn)||((Channel) == SPI_IRQn)||\
							  ((Channel) == TM0_IRQn)||((Channel) == TM1_IRQn)||\
							  ((Channel) == TM2_IRQn)||((Channel) == SARADC_IRQn)||\
							  ((Channel) == SDADC_IRQn)||((Channel) == IWDT_IRQn)||\
							  ((Channel) == WWDT_IRQn)||((Channel) == RTC_IRQn)||\
							  ((Channel) == PWM0_IRQn)||((Channel) == PWM1_IRQn))
							  
/*******************************中断向量优先级*****************************/							  
typedef enum
{
	VIC_IRQChannelPriority0 = 0x00,                        //优先级号越小，优先级越高
    VIC_IRQChannelPriority1 = 0x01,
    VIC_IRQChannelPriority2 = 0x02,
    VIC_IRQChannelPriority3 = 0x03
  
}VICPriority_TypeDef;

#define IS_VIC_Priority(Priority) (((Priority) == VIC_IRQChannelPriority0)||((Priority) == VIC_IRQChannelPriority1)||\
								   ((Priority) == VIC_IRQChannelPriority2)||((Priority) == VIC_IRQChannelPriority3))
								   
/*******************************中断向量阈值******************************/
typedef enum
{
  VIC_PrioThreshold0 = 0x00,                             //阈值号越小，级别越高  
  VIC_PrioThreshold1 = 0x01,
  VIC_PrioThreshold2 = 0x02,
  VIC_PrioThreshold3 = 0x03
  
}VICPrioThreshold_TypeDef;

#define IS_VIC_PrioThreshold(Threshold) (((Threshold) == VIC_PrioThreshold0)||((Threshold) == VIC_PrioThreshold1)||\
								         ((Threshold) == VIC_PrioThreshold2)||((Threshold) == VIC_PrioThreshold3))
										 
/*******************************中断向量相关参数配置******************************/										 
typedef struct
{
 
  IRQn_Type VIC_IRQChannel;                                //选择对应的中断向量号        
  
  VICPriority_TypeDef VIC_IRQChannelPriority;              //配置对应中断向量的优先级
  
  VICPrioThreshold_TypeDef VIC_PrioThreshold;              //配置对应中断向量优先级的比较阈值
 
  FunctionalState VIC_PrioThresholdCmd;                    //使能优先级阈值比较功能
  
  FunctionalState VIC_IRQChannelWakeUpLowPowerCmd;         //使能对应中断向量可唤醒低功耗模式
  
  FunctionalState VIC_IRQChannelCmd;                       //使能对应编号的中断通道
  
}VIC_InitTypeDef;
	

/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */ 

void VIC_DeInit(void);                                                                                     //将VIC中断相关的寄存器恢复为上电默认值

void VIC_Init(VIC_InitTypeDef* VIC_InitStruct);                                                            //初始化VIC中断相关寄存器

void VIC_IRQChannelPriorityConfig(IRQn_Type VIC_IRQChannel,VICPriority_TypeDef VIC_IRQChannelPriority);    //配置中断优先级

void VIC_PrioThresholdConfig(IRQn_Type VIC_IRQChannel,VICPrioThreshold_TypeDef VIC_PrioThreshold);         //配置中断优先级阈值

void VIC_PrioThresholdCmd(FunctionalState NewState);                                                       //使能中断优先级阈值比较

void VIC_IRQChannelCmd (IRQn_Type VIC_IRQChannel,FunctionalState NewState);                                //使能对应编号的中断通道

void VIC_IRQChannelWakeUpLowPowerCmd(IRQn_Type VIC_IRQChannel,FunctionalState NewState);                   //使能对应编号的中断可唤醒低功耗模式

void VIC_SetIRQChannelPendingStatus(IRQn_Type VIC_IRQChannel);                                             //设置对应编号的中断为挂起状态
FlagStatus VIC_GetIRQChannelPendingFlagStatus(IRQn_Type VIC_IRQChannel);                                   //获取对应编号的中断挂起状态
void VIC_ClearIRQChannelPendingFlagStatus(IRQn_Type VIC_IRQChannel);                                       //清除对应编号的中断挂起状态

FlagStatus VIC_GetIRQChannelActiveFlagStatus(IRQn_Type VIC_IRQChannel);                                    //获取对应编号的中断响应状态
void VIC_ClearIRQChannelActiveFlagStatus(IRQn_Type VIC_IRQChannel);                                        //清除对应编号的中断响应状态

uint16_t VIC_GetVECTPendingStatus(void);                                                                   //获取当前挂起的优先级最高的中断源向量号
uint16_t VIC_GetVECTActiveStatus(void);                                                                    //获取CPU当前正在处理的中断源向量号


#ifdef __cplusplus
}  
#endif

#endif /* __SD93F115B_VIC_H */



/***************************END OF FILE***************************/